package myAsm;

import java.util.Map;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Transient;

import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

@Entity
@DiscriminatorValue("INSN_IINC")
public class MyIincInsnNode extends MyAbstractInsnNode {
	
	/**
     * Index of the local variable to be incremented.
     */
	@Transient
    public int var;

    /**
     * Amount to increment the local variable by.
     */
	@Transient
    public int incr;

	public MyIincInsnNode() {
	        super(-1);
	}
	
    /**
     * Constructs a new {@link IincInsnNode}.
     * 
     * @param var index of the local variable to be incremented.
     * @param incr increment amount to increment the local variable by.
     */
    public MyIincInsnNode(final int var, final int incr) {
        super(Opcodes.IINC);
        this.var = var;
        this.incr = incr;
    }

	@Override
	public int getType() {
		 return IINC_INSN;
	}

	@Override
	public void accept(MethodVisitor mv) {
		 mv.visitIincInsn(var, incr);
	}

	@Override
	public MyAbstractInsnNode clone(Map labels) {
		return new MyIincInsnNode(var, incr);
	}

}
